//
//  UIBarButtonItem+Extension.swift
//  SinaWeibo
//
//  Created by yang on 15/11/19.
//  Copyright © 2015年 yang. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    convenience init(imageName:String,target:AnyObject?,actionName:String?){
        let btn = UIButton(type: .Custom)
        btn.setImage(UIImage(named:imageName), forState: .Normal)
        btn.setImage(UIImage(named:imageName + "_Highlighted"), forState:.Highlighted)
        if let acction = actionName,targetobj = target{
        btn.addTarget(targetobj, action: Selector(acction), forControlEvents: .TouchUpInside)
        }
        btn.sizeToFit()
        self.init(customView:btn)
    }
  
}
